import { DataTypes, Model } from "sequelize";
import sequelize from "../../sequelize";
import { ProfessionalRole } from "./ProfessionalRole";

export class ProfessionalCategory extends Model {
    declare id: number;
    declare name: string;
    declare ProfessionalRoles?: ProfessionalRole[];
}

ProfessionalCategory.init(
    {
        id: {
            type: DataTypes.INTEGER,
            allowNull: false,
            primaryKey: true,
            autoIncrement: true,
            unique: true,
        },
        name: {
            type: DataTypes.STRING,
            allowNull: false,
        },
    },
    {
        tableName: "professional-categories",
        sequelize,
        timestamps: false
    }
);

ProfessionalCategory.hasMany(ProfessionalRole, {
    foreignKey: "categoryId",
});
